import {
	CoreReg,
	Internal,
	MCU_Core
} from "./structs.slint";

import { UiIo } from "global.slint";
import { ScrollView, LineEdit } from "std-widgets.slint";

export component CtrtexMView inherits ScrollView {

	VerticalLayout {
		Text { text: "Core"; }
		VerticalLayout {
			for reg in UiIo.mcu_core.Core: Rectangle{
				background: touch.has-hover ? #c18c92 : wheat;
				HorizontalLayout {
					Text {
						width: 72px;
						text: reg.name;
					}
					value:= Text {
						text: reg.value;
					}
				}
				touch := TouchArea {
					double-clicked => {
						UiIo.copy-to-clipboard(value.text)
					}
				}
			}
		}

		Text { text: "Banked"; }
		VerticalLayout {
			for reg in UiIo.mcu_core.Banked: Rectangle{
				background: touch_banked.has-hover ? #c18c92 : #F8D800;
				HorizontalLayout {
					Text {
						width: 72px;
						text: reg.name;
					}
					value_banked:= Text {
						text: reg.value;
					}
				}
				touch_banked := TouchArea {
					double-clicked => {
						UiIo.copy-to-clipboard(value_banked.text)
					}
				}
			}
			LineEdit {
				width: root.width;
				text: UiIo.PC_str;
				placeholder-text: "HEX PC value";
			}
		}
		

		// Text { text: "System"; }
		// VerticalLayout {
		// 	for reg in UiIo.mcu_core.System: Rectangle{
		// 		background: greenyellow;
		// 		HorizontalLayout {
		// 			Text {
		// 				horizontal-stretch: 1;
		// 				text: reg.name;
		// 			}
		// 			Text {
		// 				text: reg.value;
		// 			}
		// 		}
		// 	}
		// }

		Rectangle{}
	}
}